package com.boom.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.boom.pojo.Provider;
import com.boom.service.ProviderService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/provider")
public class ProviderController {

    @Resource
    private ProviderService providerService;

    @RequestMapping("/list.html")
    public String list(Model model,@RequestParam(required = false) String queryProCode, @RequestParam(required = false) String queryProName){
        QueryWrapper<Provider> wrapper=new QueryWrapper<>();
        if (queryProCode!=null){
            wrapper.like("proCode",queryProCode);
        }
        if (queryProName!=null){
            wrapper.like("proName",queryProName);
        }
        List<Provider> list=providerService.getProvicerList(wrapper);
        model.addAttribute("providerList",list);
        return "providerlist";
    }
}
